cd "C:\Users\remij\Desktop\Replication Files JOEG\Stata"
set more off

*************************************************
*** PROGRAM THAT WE NEED FOR SOME REGRESSIONS ***
*************************************************

* this program generates a coefficient and standard error (with stars) 
* to report on a linear combination:
program drop _all
program proglincom, rclass
    lincom `0'
    local coefftxttmp = string(r(estimate),"%9.3f")
    local se = r(se)
    return local setxt = "["+string(`se',"%9.3f")+"]"
    local tstat=r(estimate)/r(se)
    gen pval = tprob(r(df), abs(`tstat'))*100
    egen pvalcat = cut(pval), at(0,1,5,10,100)
    lab def starlab 0 "***" 1 "**" 5 "*" 10 "", replace
    lab val pvalcat starlab
    decode pvalcat, gen(stars)
	local startxt = stars
	return local coefftxt = "`coefftxttmp'" + "`startxt'"
	drop pval pvalcat stars
end 
* this program generates a coefficient and standard error (with stars) 
* to report on a non-linear combination:
program prognlcom, rclass
    nlcom `0'
    matrix A = r(b)
	local coefftxttmp = string(A[1,1],"%9.3f")
	matrix B = r(V)
    local se = sqrt(B[1,1])
    return local setxt = "["+string(`se',"%9.3f")+"]"
    local tstat=A[1,1]/`se'
    gen pval = tprob(r(df_r), abs(`tstat'))*100
    egen pvalcat = cut(pval), at(0,1,5,10,100)
    lab def starlab 0 "***" 1 "**" 5 "*" 10 "", replace
    lab val pvalcat starlab
    decode pvalcat, gen(stars)
	local startxt = stars
	return local coefftxt = "`coefftxttmp'" + "`startxt'"
	display "`coefftxttmp'"
	drop pval pvalcat stars
	matrix drop A B
end 

*****************************************************************************************************

****************
****************
*** FIGURE 1 ***
****************
****************

* See the folder "Figure 1" in the main folder

****************
****************
*** FIGURE 2 ***
****************
****************

* See the folder "Figure 2" in the main folder

****************
****************
*** FIGURE 3 ***
****************
****************

use ghana_missions2, clear
keep if year >= 1840
collapse (sum) missions_num mainstat_num asstschools_num, by(year)
twoway (line missions_num year, lcolor(black) lwidth(medthick) lpattern(solid))(line mainstat_num year, lcolor(black) lwidth(medthick) lpattern(dash))(line asstschools_num year, lcolor(gs8) lwidth(medthick) lpattern(dash)), xlabel(1840(10)1930) xmtick(1840(1)1932) ytitle(Number of Cells) xtitle(.) xtitle(, size(zero) color(none)) xline(1850 1875 1897 1932, lwidth(medthick) lpattern(longdash) lcolor(gs10)) legend(order(1 "Missions" 2 "Main Mission Stations" 3 "Mission Schools") row(1)) graphregion(margin(small) fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
* We modify manually
graph use "evol_missions.gph"
graph export figure3.png, replace width(2620) height(1908)

****************
****************
*** FIGURE 4 ***
****************
****************

* See the folder "Figure 4" in the main folder

****************
****************
*** FIGURE 5 ***
****************
****************

* See the folder "Figure 5" in the main folder

*****************
*****************
*** FIGURE 6A ***
*****************
*****************

use ghana_missions2, clear
keep if year >= 1800 & year <= 1897
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
drop distyr district31
keep missions_yn histo_malaria gridnum year distyrnum latitude longitude
* We use 15 years before, 15 years after 
gen mal1835 = 0
replace mal1835 = histo_malaria if year <= 1835
foreach X of numlist 1836(1)1864 {
gen mal`X' = 0
replace mal`X' = histo_malaria if year == `X'
}
gen mal1865 = 0
replace mal1865 = histo_malaria if year >= 1865
keep missions_yn mal1835-mal1848 mal1850-mal1865 gridnum year distyrnum latitude longitude
hdfe missions_yn mal1835-mal1848 mal1850-mal1865, clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn mal1835-mal1848 mal1850-mal1865, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
regsave using temp, replace pval level(90) ci

use temp, clear
gen year = substr(var,-4,4)
destring year, replace
gen pre = "pre" if year < 1850
replace pre = "post" if year >= 1850
sum coef* ci*
twoway (connected coef year, mcolor(black) msize(medium) lcolor(black) lpattern(solid) lwidth(medthick)) (line ci_upper year if pre == "pre", lcolor(gs5) lpattern(dash))(line ci_upper year if pre == "post", lcolor(gs5) lpattern(dash))(line ci_lower year if pre == "pre", lcolor(gs5) lpattern(dash))(line ci_lower year if pre == "post", lcolor(gs5) lpattern(dash)), xline(1849.5) yline(0) ylabel(-0.006(0.002)0.014) xlabel(1835(5)1865) legend(off) ytitle(Effect (Relative to 1849))
graph use "figure6A_new.gph"
graph export figure6A.png, replace width(2620) height(1908)

*****************
*****************
*** FIGURE 6B ***
*****************
*****************

* We now run the regression.
foreach X in open {
use sample_event_study_rail, clear
foreach Z of varlist `X'pre15 `X'pre14 `X'pre13 `X'pre12 `X'pre11 `X'pre10 `X'pre9 `X'pre8 `X'pre7 `X'pre6 `X'pre5 `X'pre4 `X'pre3 `X'pre2 `X'0-`X'15 {
gen west`Z' = 0
replace west`Z' = `Z' if rail030_west == 1
}
foreach Z of varlist `X'pre15 `X'pre14 `X'pre13 `X'pre12 `X'pre11 `X'pre10 `X'pre9 `X'pre8 `X'pre7 `X'pre6 `X'pre5 `X'pre4 `X'pre3 `X'pre2 `X'0-`X'15 {
gen east`Z' = 0
replace east`Z' = `Z' if rail030_east == 1
}
foreach Z of varlist `X'pre15 `X'pre14 `X'pre13 `X'pre12 `X'pre11 `X'pre10 `X'pre9 `X'pre8 `X'pre7 `X'pre6 `X'pre5 `X'pre4 `X'pre3 `X'pre2 `X'0-`X'6 {
gen cent`Z' = 0
replace cent`Z' = `Z' if rail030_cent == 1
}
hdfe missions_yn west* east* cent*, clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn west* east* cent*, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
regsave west* east* cent* using temp, replace pval level(90) ci
}

* We now create the figure. 
foreach X in open {
use temp, clear
gen year = substr(var,-2,2)
gen pre = substr(var,-4,3)
replace pre = "pre" if pre == "re1"
replace year = subinstr(year, "e", "",.) 
replace year = subinstr(year, "n", "",.) 
drop if var == "_cons"
destring year, replace
replace year = -year if pre == "pre"
replace pre = "post" if year >= 0
gen line = substr(var,1,4)
replace line = "1. Western (1901-11)" if line == "west"
replace line = "2. Eastern (1909-23)" if line == "east"
replace line = "3. Central (1926-27)" if line == "cent"
tab line
twoway (connected coef year if year <= 0, mcolor(black) msize(medium) lcolor(black) lpattern(solid) lwidth(medthick))(connected coef year if year >= 0, mcolor(black) msize(medium) lcolor(black) lpattern(solid) lwidth(medthick))(line ci_lower year if year <= -2, lcolor(gs8) lpattern(dash) lwidth(medthick))(line ci_lower year if year >= 0, lcolor(gs8) lpattern(dash) lwidth(medthick))(line ci_upper year if year <= -2, lcolor(gs8) lpattern(dash) lwidth(medthick))(line ci_upper year if year >= 0, lcolor(gs8) lpattern(dash) lwidth(medthick)), yline(0, lwidth(medium) lpattern(soild) lcolor(gs8)) xline(-1, lwidth(medium) lpattern(solid) lcolor(gs8)) ylabel(-0.10(0.10)0.20) xlabel(-15(5)15) legend(off) xtitle(, size(zero)) ytitle(Railroad Effect in Each Year) graphregion(margin(small) fcolor(white) lcolor(white)) plotregion(margin(vsmall) fcolor(white) lcolor(white)) ytitle(, margin(small)) by(, legend(off)) by(line, rows(1)) title(rail definition = `X')
graph export panelevent_all_`X'_onebyone.png, replace width(2620) height(1908)
}
graph use "event_rail_new_completion.gph"
graph export figure6B.png, replace width(2620) height(1908)

*****************
*****************
*** FIGURE 7A ***
*****************
*****************

use ghana_missions2, clear
* We run the regression
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931"
local econ "ln_export_area slavemarket_strict_dist`X' palmoil1900_dist`X' kolanut`Y' rubber1900_dist`X' cocoa minet_dist1932_`X'"
xi: reg missions_yn `geo' `ecogeo' `pop' `econ' area_sqkm if year == 1932, robust
}
}
* We obtain the scores
predict missions_score if year == 1932, xb
ren missions_score missions_score1932
bysort gridcell: egen missions_score = max(missions_score1932) 
foreach X in missions_score {
sort gridcell year
bysort gridcell: gen lag1missions_yn = missions_yn[_n-1]
gen missiongroup = "0_0" 
replace missiongroup = "0_1" if lag1missions_yn == 0 & missions_yn == 1 
replace missiongroup = "1_0" if lag1missions_yn == 1 & missions_yn == 0
replace missiongroup = "1_1" if lag1missions_yn == 1 & missions_yn == 1
collapse (mean) `X', by(year missiongroup)
reshape wide `X', i(year) j(missiongroup) string
}
* We now create the figure
keep if year >= 1840
foreach X in missions_score {
twoway (fpfit `X'1_1 year, mcolor(black) lcolor(black))(fpfit `X'0_1 year, mcolor(blue))(fpfit `X'1_0 year, mcolor(red))(fpfit `X'0_0 year, mcolor(gs8) lcolor(gs8)), legend(order(1 "Remains 1" 2 "Becomes 1" 3 "Becomes 0" 4 "Remains 0") row(1)) xlabel(1840(10)1930)
graph export decomp_`X'_4grps.png, replace width(2620) height(1908)
}
* We modify manually before exporting
graph export figure7a.png, replace width(2620) height(1908)

*****************
*****************
*** FIGURE 7B ***
*****************
*****************

* We create the data that we need for the figure. 
* Beach data (protestants only)
use "Beach1903_grid.dta", clear
ren beach1900 beach03_pro_num
gen beach03_pro_yn = (beach03_pro_num > 0 & beach03_pro_num != .)
label var beach03_pro_yn "Dummy if Protestant Missions in 1903 (Beach Map)"
sort gridcell
save beach03_v2, replace

* Roome data (protestants and catholics)
use "roome24_grid.dta", clear
gen roome24_pro_yn = (roome24_protestant > 0 & roome24_protestant != .)
gen roome24_cat_yn = (roome24_catholics > 0 & roome24_catholics != .)
gen roome24_mis_yn = (roome24_pro_yn == 1 | roome24_cat_yn == 1)
egen roome24_mis_num = rsum(roome24_protestant roome24_catholics)
ren roome24_protestant roome24_pro_num 
ren roome24_catholics roome24_cat_num
drop roome24_bfbs
order gridcell roome24_mis_yn roome24_mis_num roome24_pro_yn roome24_pro_num roome24_cat_yn roome24_cat_num  
label var roome24_mis_yn "Dummy if Missions (Protestants & Catholics) in 1924 (Roome Map)"
label var roome24_mis_num "Number of Missions (Protestants & Catholics) in 1924 (Roome Map)"
label var roome24_pro_yn "Dummy if Protestant Missions in 1924 (Roome Map)"
label var roome24_cat_yn "Dummy if Catholic Missions in 1924 (Roome Map)"
sort gridcell
save roome24_v2, replace

* We create the main data set. 
use ghana_missions2, clear
bysort year: egen summissions_num = sum(missions_num)
sum year if summissions_num >= 10
* 1841: first year with 10 missions. We thus start in 1841.
keep if year >= 1841 & year <= 1932
* We add the mission data for this analysis only. 
sort gridcell
merge gridcell using roome24_v2
tab _m
drop _m
sort gridcell
merge gridcell using beach03_v2
tab _m
drop _m
gen protestant_yn = ((cmeth > 0 & cmeth !=.) | (cpresb > 0 & cpresb != .) | (coth > 0 & coth != .))          
egen protestant_num = rsum(cmeth cpresb coth) 
keep year missions_yn missions_num protestant_yn protestant_num beach03_* roome24* longitude latitude  
save data_for_comparison, replace

* Correlation for Beach
quietly {
use data_for_comparison, clear
parmby "regr beach03_pro_yn protestant_yn, nocons robust", by(year) label command norestore
keep if parm == "protestant_yn" 
keep year estimate
ren estimate beach03_pro_yn
sort year
save beach03_pro_yn, replace
}

* Correlation for Roome
quietly {
use data_for_comparison, clear
parmby "regr roome24_mis_yn missions_yn, nocons robust", by(year) label command norestore
keep if parm == "missions_yn" 
keep year estimate
ren estimate roome24_mis_yn
sort year
save roome24_mis_yn, replace
}

* We now create the figure.
use beach03_pro_yn, clear
sort year
merge using roome24_mis_yn
tab _m
drop _m
twoway (line roome24_mis_yn year, lcolor(black) lpattern(solid) lwidth(medthick))(line beach03_pro_yn year, lcolor(black) lpattern(dash) lwidth(medthick)), legend(order(1 "Roome (1925) in 1924" 2 "Beach (1903) in 1900" ) row(1)) xlabel(1840(10)1930) ylabel(0(0.1)1) ytitle(Correlation of Atlas Missions with Our Missions Year t) ytitle(, margin(medsmall)) xtitle(Year for Our Data Set) xtitle(, margin(medsmall))  graphregion(margin(small) fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xline(1900 1924, lwidth(medium) lpattern(longdash) lcolor(gs4))
graph use "correlation_dummies.gph"
* We modify manually before exporting
graph export Figure7B.png, replace width(2620) height(1908)

* Erase the file we don't need. 
capture erase "data_for_comparison.dta"

*****************
*****************
*** FIGURE A4 ***
*****************
*****************

use temp_cashc, clear
collapse (sum) palmpval_uk rubbpval_uk kolapval_uk cocoapval_uk, by(year)
* We use the shares
egen sum = rsum(palmpval_uk rubbpval_uk kolapval_uk cocoapval_uk)
foreach X in palmpval_uk rubbpval_uk kolapval_uk cocoapval_uk {
replace `X' = `X' / sum*100
}
graph use "cashcrop.gph"
graph export figureA4.png, replace width(2620) height(1908)

***************
***************
*** TABLE 1 ***
***************
***************

use ghana_missions2, clear
* We keep the main years for the cross-sectional regressions.
keep if year == 1850 | year == 1875 | year == 1897 | year == 1932
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "ldist2coast port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931"
local econ "ln_export_area slavemarket_strict_dist`X' palmoil1900_dist`X' kolanut`Y' rubber1900_dist`X' cocoa minet_dist1932_`X'"
acreg missions_yn `geo' `ecogeo' `pop' `econ' area_sqkm if year == 1850, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table1.xls, addtext(year, 1850) keep(histo_malaria ldist2coast port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 *upop* *rpop* palm* kola* cocoa*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
acreg missions_yn missions_yn1850 `geo' `ecogeo' `pop' `econ' area_sqkm  if year == 1875, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table1.xls, addtext(year, 1875) keep(missions_yn* histo_malaria ldist2coast port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 *upop* *rpop* palm* kola* cocoa*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
acreg missions_yn missions_yn1875 `geo' `ecogeo' `pop' `econ' area_sqkm  if year == 1897, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table1.xls, addtext(year, 1897) keep(missions_yn* histo_malaria ldist2coast port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 *upop* *rpop* palm* kola* cocoa*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
acreg missions_yn missions_yn1897 `geo' `ecogeo' `pop' `econ' area_sqkm  if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table1.xls, addtext(year, 1932) keep(missions_yn* histo_malaria ldist2coast port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 *upop* *rpop* palm* kola* cocoa*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
}
* For the missing SEs in column (4), we use this older program created by Conley himself *
* 1932
run gls_sptl.005.do
keep if year == 1932
*gls_sptl missions_yn missions_yn1897 prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50 area_sqkm, sptlcoef(1) crdlst(latitude longitude) cut(100) 
* The coefficient for which there is an issue is the coefficient of ldist2coast. Based on the SE, we report ***.

***************
***************
*** TABLE 2 ***
***************
***************

clear
clear matrix
clear mata
set matsize 11000
set maxvar 32767
set emptycells drop 

***** COLUMNS 1-7: MISSIONS *****

* We use the main data set to create a data set with only the variables we need. 
use ghana_missions2, clear
gen ashanti = (region_4 == "Ashanti")
sort gridcell year
keep missions_yn region_4 longitude latitude ashanti nongcc1873 histo_malaria gridcell year ethnic district31 
gen pre0024 = (year >= 1800 & year < 1824)
gen pre0024m = pre0024*histo_malaria
gen post5097 = (year >= 1850 & year <= 1897)
gen post5097m = post5097*histo_malaria
gen post5072 = (year >= 1850 & year <= 1872)
gen post5072m = post5072*histo_malaria
gen post7397 = (year >= 1873 & year <= 1897)
gen post7397m = post7397*histo_malaria
gen post1898 = (year > 1897)
gen post1898m = post1898*histo_malaria
foreach X in 5097 5072 7397 1898 {
label var post`X' "Dummy if `X' period"
label var post`X'm "Dummy if `X' period * malaria suitability"
}
label var ashanti "Ashanti province dummy"
foreach X in 0024 {
label var pre`X' "Dummy if `X' period"
label var pre`X'm "Dummy if `X' period * malaria suitability"
}
egen gridnum = group(gridcell)
label var gridnum "Grid num"
save temp, replace

* 1 BASELINE
use temp, clear
keep if year >= 1800 & year <= 1897
hdfe missions_yn post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using table2.xls, keep(post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace

* 2 PARALLEL TRENDS
use temp, clear
keep if year >= 1800 & year <= 1897
hdfe missions_yn pre0024m post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn pre0024m post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 pre0024m post5097m using table2.xls, keep(pre0024m post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

* 3 DISTRICT-YEAR FE
use temp, clear
keep if year >= 1800 & year <= 1897
* We create the district-year variables. 
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
* We drop other variables we don't need.
drop distyr district31
hdfe missions_yn post5097m, clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using table2.xls, keep(pre2549m post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

* 4 BASELINE + GCC + ASHANTI 
use temp, clear
keep if year >= 1800 & year <= 1897
hdfe missions_yn post5097m, clear absorb(gridnum year i.year#i.nongcc1873 i.year#i.ashanti) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using table2.xls, keep(post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

* 5 DISTRICT-YEAR FE + GCC + ASHANTI 
use temp, clear
keep if year >= 1800 & year <= 1897
* We create the district-year variables. 
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
* We drop other variables we don't need.
drop distyr district31
hdfe missions_yn post5097m, clear absorb(gridnum year distyrnum i.year#i.nongcc1873 i.year#i.ashanti) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using table2.xls, keep(pre2549m post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

* 6 BASELINE - TWO SUBPERIODS
use temp, clear
keep if year >= 1800 & year <= 1897
* We create the two subperiod dummies. 
gen post5070 = (year >= 1850 & year <= 1870)
gen post5070m = post5070*histo_malaria
gen post7197 = (year >= 1871 & year <= 1897)
gen post7197m = post7197*histo_malaria
hdfe missions_yn post5070m post7197m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5070m post7197m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5070m post7197m using table2.xls, keep(post5070m post7197m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

* 7 DISTRICT-YEAR FE + TWO SUBPERIODS
use temp, clear
keep if year >= 1800 & year <= 1897
* We create the district-year variables. 
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
* We drop other variables we don't need.
drop distyr district31
* We create the two subperiod dummies. 
gen post5070 = (year >= 1850 & year <= 1870)
gen post5070m = post5070*histo_malaria
gen post7197 = (year >= 1871 & year <= 1897)
gen post7197m = post7197*histo_malaria
hdfe missions_yn post5070m post7197m, clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn post5070m post7197m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5070m post7197m using table2.xls, keep(post5070m post7197m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

***** COLUMNS 8-11: MISSIONARIES *****

use ghana_missions2, clear
keep if year >= 1846 & year <= 1890
sort gridcell year
gen p50 = (year >= 1850)
gen post1850m = p50*histo_malaria
* Cols 8-11 *
xi: reg2hdfespatial promissions_yn post1850m if euroyr != ., timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 * using table2.xls, keep(post1850m) addtext(type, methpresb, post, 1850, sample, 1846-1890, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
xi: reg2hdfespatial euroyr post1850m, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 * using table2.xls, keep(_Ip*X*) addtext(type, euroall, post, 1850, sample, 1846-1890, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
xi: reg2hdfespatial euromainyr post1850m, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 * using table2.xls, keep(_Ip*X*) addtext(type, euromain, post, 1850, sample, 1846-1890, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
xi: reg2hdfespatial afrimainyr post1850m, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 * using table2.xls, keep(_Ip*X*) addtext(type, afrimain, post, 1850, sample, 1846-1890, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

***************
***************
*** TABLE 3 ***
***************
***************

*** PANEL A: CROSS-SECTIONAL/LONG-DIFFERENCE ANALYSIS ***
use ghana_missions2, clear
* We create a few more variables just for this set of regressions.
* 30 km railroad dummy in 1932:
drop dist2rail
ren dist2rail1932 dist2rail 
gen rail030 = (dist2rail <= 30 & dist2rail != .)
* 30 km dummy for the Eastern line:
gen rail030_nowest = (rail030 == 1 & dist2west18_030 == 0)
* 30 km dummy for the "pure" placebo cells. 
gen dist2placebo_030_norail = (dist2placebo_030 == 1 & rail030 == 0)

* ROWS 1-4: BASELINE AND PARALLEL TRENDS
capture erase table3A.xls
capture erase table3A.txt
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
* 1932 *
acreg missions_yn missions_yn1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1850 *
acreg missions_yn `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1850, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1850) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1875 *
acreg missions_yn missions_yn1850 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1875, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1875) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1897 *
acreg missions_yn missions_yn1875 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1897, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1897) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
* ROWS 5-6: ETHNIC/DISTRICT FE
foreach W in ethnic district31 {
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
xi: acreg missions_yn missions_yn1897 `rail' `geo' `ecogeo' `pop' `econ' area_sqkm i.`W' if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1897-1932, test, `W' FE) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
}
* ROW 7: WESTERN LINE 
quietly {
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "dist2west18_030 rail030_nowest"
xi: acreg missions_yn missions_yn1897 `rail' `geo' `ecogeo' `pop' `econ' area_sqkm  if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1897-1932, test, western) keep(`rail') br se nocons coefastr bdec(3) sdec(4) rdec(2) noni nolabel
}
}
}
* ROW 8: PLACEBO
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "dist2placebo_030_norail rail030"
xi: acreg missions_yn missions_yn1897 `rail' `geo' `ecogeo' `pop' `econ' area_sqkm  if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table3A.xls, addtext(year, 1897-1932, test, placebo) keep(`rail') br se nocons coefastr bdec(3) sdec(4) rdec(2) noni nolabel
}
}
* ROW 9: IV STRAIGHT LINE
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
local ivrail "dist2iv_030"
xi: ivreg2 missions_yn missions_yn1897 (`rail' = `ivrail') `geo' `ecogeo' `pop' `econ' area_sqkm lnode_dist  if year == 1932 & node_dist > 10, robust cluster(district31) first
outreg2 * using table3A.xls, addtext(year, 1897-1932, test, iv straight) keep(`rail') br se nocons coefastr bdec(3) sdec(4) rdec(2) noni nolabel
}
}

***** PANEL B: PANEL ANALYSIS FOR RAILROADS *****

use ghana_missions2, clear
keep if year >= 1897
gen rail030 = (dist2rail <= 30 & dist2rail != .)
sort gridcell year
foreach X of numlist 1(1)3 {
bysort gridcell: gen lag`X'rail030 = rail030[_n-`X']
bysort gridcell: gen lead`X'rail030 = rail030[_n+`X']
}
gen ethnicyr = ethnic+string(year)
gen distyr = district31+string(year)
keep missions_yn *rail030 gridcell year gridcell rail030 ethnic district31 longitude latitude
egen gridnum = group(gridcell)
keep gridcell gridnum year missions_yn *rail030 longitude latitude ethnic district31
sort gridnum year 
bysort gridnum: gen lag1missions_yn = missions_yn[_n-1]
sort gridcell
save temp, replace

use temp, clear
capture erase table3B.xls
capture erase table3B.txt
capture erase table3B.tex
** ROW 10 **
xi: reg2hdfespatial missions_yn rail030, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 rail* using table3B.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
** ROW 11 **
xi: reg2hdfespatial missions_yn rail030 lead1rail030, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 rail* using table3B.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
** ROW 12 ** 
xi: reg2hdfespatial missions_yn rail030 lag1rail030, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 rail* using table3B.xls, keep(*rail*) addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
lincom lag1rail030
** ROW 13 **
set matsize 10000
gen ethnicyr = ethnic+string(year)
egen ethnicyrnum = group(ethnicyr)
drop ethnicyr ethnic
hdfe missions_yn rail030, clear absorb(gridnum year ethnicyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn rail030, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 rail* using table3B.xls, keep(*rail*) addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel

** ROW 14 **
use temp, clear
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
hdfe missions_yn rail030, clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn rail030, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 rail* using table3B.xls, keep(*rail*) addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel

** ROW 15: CELL-LINEAR TRENDS **
set matsize 10000
use temp, clear
sort gridcell year
keep missions_yn *rail030 gridcell year gridcell longitude latitude district31
egen gridnum = group(gridcell)
keep gridnum year missions_yn *rail030 longitude latitude district31
* We create the cell-specific linear trends. 
foreach X of numlist 1(1)1000 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
foreach X of numlist 1001(1)2091 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
set matsize 10000
set more on 
xi: reg missions_yn rail030 gridyear1-gridyear2091, robust cluster(district31)
outreg2 rail* using table3B.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel

**********************************************
**********************************************
*** TABLE 4: PANEL ANALYSIS FOR CASH CROPS ***
**********************************************
**********************************************

***** TABLE 4 FOR DRAFT *****

use temp_cashc, clear
* 1) Cash crop value based on production dummies 
foreach Z in cashc {
foreach X in uk {
xi: reg2hdfespatial missions_yn l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* using table4.xls, keep(*l*val_`X') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
}
}
* 2)-3) Cash crop value based on suitability dummies
foreach Z in cashcs2 cashcs {
foreach X in uk {
xi: reg2hdfespatial missions_yn l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* using table4.xls, keep(*l*val_`X') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
}
* 4)-7) Each crop one by one 
foreach Z in palmp rubbp kolap cocoap {
foreach X in uk {
xi: reg2hdfespatial missions_yn l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* using table4.xls, keep(*l*val_`X') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
}
* 8) Cash crop value based on cocoa suitability dummies of three types
foreach Z in cashco2cs {
foreach X in uk {
xi: reg2hdfespatial missions_yn l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* using table4.xls, keep(*l*val_`X') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
}
* 9) Effect of lead
local lincomset "lead1lcashcval_`X'"
foreach X in uk {
xi: reg2hdfespatial missions_yn lcashcval_`X' lead1lcashcval_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
proglincom "`lincomset'"
outreg2 *lcashcval_`X'* lead1lcashcval_`X' using table4.xls, keep(*lcashcval_`X' lead1lcashcval_`X') addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* 10) Effect of lag
local lincomset "lcashcval_`X' + lag1lcashcval_`X'"
foreach X in uk {
xi: reg2hdfespatial missions_yn lcashcval_`X' lag1lcashcval_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
proglincom "`lincomset'"
outreg2 *lcashcval_`X'* lag*lcashcval_`X' using table4.xls, keep(lcashcval_`X' lag*lcashcval_`X') addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* 11) Including ethnic-year FE
set matsize 10000
gen ethnicyr = ethnic+string(year)
egen ethnicyrnum = group(ethnicyr)
drop ethnicyr ethnic
foreach Z in cashc {
foreach X in uk {
hdfe missions_yn l`Z'val_`X', clear absorb(gridnum year ethnicyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn l`Z'val_`X', lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 l`Z'val_`X' using table4.xls, keep(*rail*) addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
* 12) Including district-year FE
use temp_cashc, clear
set matsize 10000
gen distyr = district31+string(year)
egen distyrnum = group(distyr)
drop distyr district31
foreach Z in cashc {
foreach X in uk {
hdfe missions_yn l`Z'val_`X', clear absorb(gridnum year distyrnum) tol(0.001) keepvars(gridnum year latitude longitude)
ols_spatial_HAC missions_yn l`Z'val_`X', lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 l`Z'val_`X' using table4.xls, keep(*rail*) addtext(joint, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
* 13) Cell-specific trends *
use temp_cashc, clear
keep missions_yn lcashcval_uk year gridnum district31
foreach X of numlist 1(1)1000 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
foreach X of numlist 1001(1)2091 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
set more on
xi: reg missions_yn lcashcval_uk gridyear1-gridyear2091, robust cluster(district31)
outreg2 lcashcval_uk using table4.xls, keep(lcashcval_uk) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

***************
***************
*** TABLE 5 ***
***************
***************

***** PANEL A: CROSS-SECTIONAL IDENTIFICATION STRATEGIES *****

use grid_africa_final, clear
gen countryethnic = country+ethnic
gen cntrydistrict2000 = country+district2000
*** COLUMN 1 ***
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
local ours00murd2_milmin "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail1900_milmin30 density1800m dist2nationalcity10 slavery ln_export_area polygamy mines1900_50km"
* Baseline
foreach X in beach03_pro_yn { 
areg `X' area_sqkm `ours00murd2', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
}
* Ethnic FE
foreach X in beach03_pro_yn { 
xi: areg `X' area_sqkm `ours00murd2' i.country, robust absorb(ethnic) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* District FE
foreach X in beach03_pro_yn { 
xi: areg `X' area_sqkm `ours00murd2' i.country, robust absorb(district2000) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* Military-Mining
foreach X in beach03_pro_yn { 
areg `X' area_sqkm `ours00murd2_milmin', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1900_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* IV
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
foreach X in beach03_pro_yn { 
xi: ivreg2 `X' area_sqkm (dist2rail190030 = dist2emst30) `ours00murd2' i.country if emst_node == 0, robust cluster(district2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* Never built 1916-1922
foreach X in beach03_pro_yn { 
areg `X' dist2proposed19162230_v2_00 area_sqkm `ours00murd2', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
}
*** COLUMN 2 ***
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192430 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
local ours24murd2_milmin "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 dist2rail1924_milmin30 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy mines1900_50km"
* Baseline
foreach X in roome24_mis_yn { 
areg `X' area_sqkm `ours24murd2', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* Ethnic FE
foreach X in roome24_mis_yn { 
xi: areg `X' area_sqkm `ours24murd2' i.country, robust absorb(ethnic) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* District FE
foreach X in roome24_mis_yn { 
xi: areg `X' area_sqkm `ours24murd2' i.country, robust absorb(district2000) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* Military-Mining
foreach X in roome24_mis_yn { 
areg `X' area_sqkm `ours24murd2_milmin', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1924_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* IV
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
foreach X in roome24_mis_yn { 
xi: ivreg2 `X' area_sqkm (dist2rail192430 = dist2emst30) `ours24murd2' i.country if emst_node == 0, robust  cluster(district2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}
* Never built 1916-1922
foreach X in roome24_mis_yn { 
areg `X' dist2proposed19162230_v2_24 area_sqkm `ours24murd2', robust absorb(country) cluster(cntrydistrict2000)
outreg2 * using table5_panelA.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
}

***** PANEL B: COLUMN 1 *****

use panel_rail_africa, clear
* (7) BASELINE
reghdfe mission_yn rail30 if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col1.xls, addtext(year, 1885, test, base) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel replace
* (8) ADDING ONE LEAD
reghdfe mission_yn rail30 lead1rail if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col1.xls, addtext(year, 1885, test, lag) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
* (9) ADDING ONE LAG 
reghdfe mission_yn rail30 lag1rail if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
lincom rail30 + lag1rail
outreg2 * using table5_panelB_col1.xls, addtext(year, 1885, test, lag) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
* (10) ETHNIC-YEAR FE
gen ethnicyr = cntryyr + ethnic
reghdfe mission_yn rail30 if year >= 1885, absorb(gridcell year ethnicyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col1.xls, addtext(year, 1885, test, ethnic-yr FE) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
drop ethnicyr
* (11) DISTRICT-YEAR FE
gen distyr = cntrydistrict2000+string(year)
reghdfe mission_yn rail30 if year >= 1885, absorb(gridcell year distyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col1.xls, addtext(year, 1885, test, dist-yr FE) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
drop distyr

***** PANEL B: COLUMN 2 *****

use panel_cashc_africa, clear
foreach Z in 0 {
* (7) BASELINE
reghdfe mission_yn lcellvalue`Z'all, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col2.xls, addtext(test, base) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel replace
* (8) ADDING ONE LEAD
reghdfe mission_yn lcellvalue`Z'all lead1val`Z', absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col2.xls, addtext(test, lead) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
* (9) ADDING ONE LAG 
reghdfe mission_yn lcellvalue`Z'all lag1val`Z', absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
lincom lcellvalue`Z'all + lag1val`Z'
outreg2 * using table5_panelB_col2.xls, addtext(test, lag) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
* (10) ETHNIC-YEAR FE
gen ethnicyr = cntryyr + ethnic
reghdfe mission_yn lcellvalue`Z'all, absorb(gridcell year ethnicyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col2.xls, addtext(test, ethnic-yr FE) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
drop ethnicyr
* (11) DISTRICT-YEAR FE
gen distyr = cntrydistrict2000+string(year)
reghdfe mission_yn lcellvalue`Z'all, absorb(gridcell year distyr) vce(cluster cntrydistrict2000)
outreg2 * using table5_panelB_col2.xls, addtext(test, dist-yr FE) br se nocons coefastr bdec(4) sdec(4) rdec(4) noni nolabel append
drop distyr
}

***************
***************
*** TABLE 6 ***
***************
***************

use grid_africa_final, clear
count
* 203,574
* We cluster SEs at the district level
* Since some districts may have the same district name across countries, we create country-district identifiers.
gen cntrydistrict2000 = country+district2000
local std "prec_mean soil5 malaria dist2coast city1400 city1800 dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m ln_export_area"
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192410 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1924all mines1924_50km polygamy"
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1900all mines1900_50km polygamy"
keep country gridcell longitude latitude beach03_pro_yn roome24_mis_yn foundyr in_BEACH* dist2muslimcentre dist2nationalcity `ours00murd2' `ours24murd2' `std' area_sqkm cntrydistrict2000

local ours00murd2 "malaria tsetse lndist2coast city1400 dist2nationalcity10 date_col centra ldist2muslimcentre dist2slaveport_10km dist2river_nav10km dist2explorer10 dist2rail190010 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1900all polygamy yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 city1800 missing_murdock nevercolonised dist2lake10 density1800m mines1900_50km"
local ours24murd2 "malaria tsetse lndist2coast city1400 dist2nationalcity10 date_col centra ldist2muslimcentre dist2slaveport_10km dist2river_nav10km dist2explorer10 dist2rail192410 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1924all polygamy yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 city1800 missing_murdock nevercolonised dist2lake10 density1800m mines1924_50km"
** (1) Beach *
foreach X in beach03_pro_yn { 
areg `X' area_sqkm `ours00murd2', robust absorb(country) clust(cntrydistrict2000)
outreg2 * using table6.xls, addtext(FE, country, cluster_SE, dist2000, controls, ours00murd) br se nocons coefastr bdec(4) sdec(4) rdec(2) noni nolabel replace
}
* (2) Roome *
foreach X in roome24_mis_yn { 
areg `X' area_sqkm `ours24murd2', robust absorb(country) clust(cntrydistrict2000)
outreg2 * using table6.xls, addtext(FE, country, cluster_SE, dist2000, controls, ours24murd) br se nocons coefastr bdec(4) sdec(4) rdec(2) noni nolabel append
}
** (3)-(5) 3 periods **
* We drop the cells with a Beach mission and missing information on the foundation year.
gen missing = (in_BEACH == 1 & foundyr == 0)
drop if missing == 1
drop missing 
* (3) 1850
areg in_BEACH_1850 area_sqkm `ours00murd2', robust absorb(country) clust(cntrydistrict2000)
outreg2 * using table6.xls, addtext(FE, country, cluster_SE, dist2000, controls, ours00murd) br se nocons coefastr bdec(4) sdec(4) rdec(2) noni nolabel append
* (4) 1881
areg in_BEACH_1881 area_sqkm `ours00murd2' in_BEACH_1850, robust absorb(country) clust(cntrydistrict2000)
outreg2 * using table6.xls, addtext(FE, country, cluster_SE, dist2000, controls, ours00murd) br se nocons coefastr bdec(4) sdec(4) rdec(2) noni nolabel append
* (5) 1900
areg in_BEACH_1900 area_sqkm `ours00murd2' in_BEACH_1881, robust absorb(country) clust(cntrydistrict2000)
outreg2 * using table6.xls, addtext(FE, country, cluster_SE, dist2000, controls, ours00murd) br se nocons coefastr bdec(4) sdec(4) rdec(2) noni nolabel append

***************
***************
*** TABLE 7 ***
***************
***************

*** COLUMNS (1)-(5) BEACH 1900 ***
use ghana_missions2, clear
keep if year == 1900 
acreg station_beach_yn missions_yn, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel replace
acreg station_beach_yn missions_yn period1 period2, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_beach_yn missions_yn mainstat_yn asstschools_yn lmissions_num, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_beach_yn missions_yn eurononmain4690 euromain4690, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_beach_yn missions_yn period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append

*** COLUMNS (6)-(10) ROOME 1924 ***
use ghana_missions2, clear
keep if year == 1924 
acreg station_roome_yn missions_yn, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_roome_yn missions_yn period1 period2, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_roome_yn missions_yn mainstat_yn lmissions_num asstschools_yn, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_roome_yn missions_yn eurononmain4690 euromain4690, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_roome_yn missions_yn eurononmain4690 euromain4690, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg station_roome_yn missions_yn period1 period2 lmissions_num  mainstat_yn asstschools_yn eurononmain4690 euromain4690, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using table5.xls, addtext(cell, 1x1) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append

***************
***************
*** TABLE 8 ***
***************
***************

use ghana_missions2, clear

capture erase table8A.xls
capture erase table8A.txt
capture erase table8A.tex

*** ROW 1 ***
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
* 1900
acreg `X' missions_yn  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using table8A.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `stdctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using table8A.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ssactrls1900' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using table8A.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using table8A.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using table8A.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 1924
acreg `X' missions_yn area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using table8A.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `stdctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using table8A.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ssactrls1924' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using table8A.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using table8A.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using table8A.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}

*** ROW 2 ***
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
gen diff = missions_yn - beach03_pro_yn
acreg `X' diff beach03_pro_yn area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 diff beach03_pro_yn using table8A.xls, keep(diff beach03_pro_yn) addtext(controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff beach03_pro_yn `stdctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 diff beach03_pro_yn using table8A.xls, keep(diff beach03_pro_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff beach03_pro_yn `ssactrls1900'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 diff beach03_pro_yn using table8A.xls, keep(diff beach03_pro_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff beach03_pro_yn `ourctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 diff beach03_pro_yn using table8A.xls, keep(diff beach03_pro_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff beach03_pro_yn `type' `ourctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 diff beach03_pro_yn using table8A.xls, keep(diff beach03_pro_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
drop diff
gen diff = missions_yn - roome24_mis_yn
acreg `X' diff roome24_mis_yn  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 diff roome24_mis_yn using table8A.xls, keep(diff roome24_mis_yn) addtext(controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff roome24_mis_yn `stdctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 diff roome24_mis_yn using table8A.xls, keep(diff roome24_mis_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff roome24_mis_yn `ssactrls1924'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 diff roome24_mis_yn using table8A.xls, keep(diff roome24_mis_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff roome24_mis_yn `ourctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 diff roome24_mis_yn using table8A.xls, keep(diff roome24_mis_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' diff roome24_mis_yn `type' `ourctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 diff roome24_mis_yn using table8A.xls, keep(diff roome24_mis_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
drop diff
}

*** ROW 3 ***
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' beach03_pro_yn area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 beach03_pro_yn using table8A.xls, keep(beach03_pro_yn) addtext(controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' beach03_pro_yn `stdctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 beach03_pro_yn using table8A.xls, keep(beach03_pro_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' beach03_pro_yn `ssactrls1900'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 beach03_pro_yn using table8A.xls, keep(beach03_pro_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' beach03_pro_yn `ourctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 beach03_pro_yn using table8A.xls, keep(beach03_pro_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' beach03_pro_yn `type' `ourctrls'  area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 beach03_pro_yn using table8A.xls, keep(beach03_pro_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' roome24_mis_yn  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 roome24_mis_yn using table8A.xls, keep(roome24_mis_yn) addtext(controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' roome24_mis_yn `stdctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 roome24_mis_yn using table8A.xls, keep(roome24_mis_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' roome24_mis_yn `ssactrls1924'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 roome24_mis_yn using table8A.xls, keep(roome24_mis_yn) addtext(controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' roome24_mis_yn `ourctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 roome24_mis_yn using table8A.xls, keep(roome24_mis_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' roome24_mis_yn `type' `ourctrls'  area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 roome24_mis_yn using table8A.xls, keep(roome24_mis_yn) addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}

***** PANEL B *****

use grid_africa_final, clear
gen countrydist = country+district2000
capture erase table8B.xls
capture erase table8B.tex
capture erase table8B.txt
local std "prec_mean soil5 malaria dist2coast city1400 city1800 dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m ln_export_area"
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192410 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1924all mines1924_50km polygamy"
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1900all mines1900_50km polygamy"
local type "in_BEACH_1850 in_BEACH_185181"
foreach Z in lnltc2010 {
foreach X in beach03_pro_yn { 
areg `Z' `X' area_sqkm, robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
areg `Z' `X' area_sqkm `std', robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
areg `Z' `X' area_sqkm `ours00murd2', robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
foreach X in roome24_mis_yn { 
areg `Z' `X' area_sqkm, robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
areg `Z' `X' area_sqkm `std', robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
areg `Z' `X' area_sqkm `ours24murd2', robust absorb(country) clust(countrydist)
outreg2 * using table8B.xls, keep(`X') addtext(FE, country, cluster_SE, no, controls, ours00murd) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
}

***************
***************
*** TABLE 9 ***
***************
***************

use ghana_missions2, clear
** Panel A **
capture erase table9A.xls
capture erase table9A.txt
capture erase table9A.tex
foreach X in lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local typectrls1900 "early1_yn early2_yn "
acreg `X' missions_yn `typectrls1900' `stdctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1900') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "lmissions_num mainstat_yn1900 asstschools_yn1900"
acreg `X' missions_yn `typectrls1900' `stdctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1900') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1900' `stdctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1900') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "early1_yn early2_yn lmissions_num mainstat_yn1900 asstschools_yn1900 eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1900' `stdctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1900') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "early1_yn early2_yn "
acreg `X' missions_yn `typectrls1924' `stdctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1924') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "lmissions_num mainstat_yn1924 asstschools_yn1924 "
acreg `X' missions_yn `typectrls1924' `stdctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1924') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1924' `stdctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1924') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "early1_yn early2_yn lmissions_num mainstat_yn1924 asstschools_yn1924 eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1924' `stdctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9A.xls, keep(missions_yn `typectrls1924') addtext(controls, std) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
** Panel B **
capture erase table9B.xls
capture erase table9B.txt
capture erase table9B.tex
foreach X in lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local typectrls1900 "early1_yn early2_yn "
acreg `X' missions_yn `typectrls1900' `ourctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1900') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "lmissions_num mainstat_yn1900 asstschools_yn1900"
acreg `X' missions_yn `typectrls1900' `ourctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1900') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1900' `ourctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1900') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1900 "early1_yn early2_yn lmissions_num mainstat_yn1900 asstschools_yn1900 eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1900' `ourctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1900') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom missions_yn+early1_yn
lincom missions_yn+early2_yn
local typectrls1924 "early1_yn early2_yn "
acreg `X' missions_yn `typectrls1924' `ourctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1924') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "lmissions_num mainstat_yn1924 asstschools_yn1924 "
acreg `X' missions_yn `typectrls1924' `ourctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1924') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1924' `ourctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1924') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local typectrls1924 "early1_yn early2_yn lmissions_num mainstat_yn1924 asstschools_yn1924 eurononmain4690 euromain4690"
acreg `X' missions_yn `typectrls1924' `ourctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn using table9B.xls, keep(missions_yn `typectrls1924') addtext(controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom missions_yn+early1_yn
lincom missions_yn+early2_yn
}
* For the missing SEs, we use a program created by Conley himself. 
* Col (2)
*gls_sptl lnltc2010 missions_yn1900 early1_yn early2_yn lmissions_num mainstat_yn1900 asstschools_yn1900 eurononmain4690 euromain4690 prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50, sptlcoef(1) crdlst(latitude longitude) cut(100) 
* Col (4)
*gls_sptl lnltc2010 missions_yn1900 lmissions_num mainstat_yn1900 asstschools_yn1900 prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50, sptlcoef(1) crdlst(latitude longitude) cut(100) 

****************
****************
*** TABLE A3 ***
****************
****************

clear
clear matrix
clear mata
set matsize 11000
set maxvar 32767
set emptycells drop 

* We create a temporary file which we use below
use ghana_missions2, clear
keep if year >= 1800 
sort gridcell year
* We create simple denomination variables
gen mainline = ((cmeth > 0 & cmeth != 0) | (cpresb > 0 & cpresb != 0))
gen catho = (ccath > 0 & ccath != 0)
gen otprot = (coth > 0 & coth != 0)
* We only keep the variables we need
keep missions_yn lmissions_num mainstat_yn asstschools_yn mainline catho otprot longitude latitude histo_malaria gridcell year ethnic district31 
* Pre/post*malaria dummies 
gen pre2549 = (year >= 1825 & year < 1850)
gen pre2549m = pre2549*histo_malaria
gen post5097 = (year >= 1850 & year <= 1897)
gen post5097m = post5097*histo_malaria
gen post1898 = (year > 1897)
gen post1898m = post1898*histo_malaria
egen gridnum = group(gridcell)
keep if year >= 1800 & year <= 1897
sort gridnum year 
save temp, replace

* BASELINE
use temp, clear
hdfe missions_yn post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using tableA3.xls, keep(pre2549m post5097m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
* LOG NUMBER OF MISSIONS *
use temp, clear
hdfe lmissions_num missions_yn post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC lmissions_num missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m missions_yn using tableA3.xls, keep(pre2549m post5097m post1898m missions_yn) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* MAIN STAT *
use temp, clear
hdfe mainstat_yn missions_yn post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC mainstat_yn missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m missions_yn using tableA3.xls, keep(pre2549m post5097m post1898m missions_yn) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* SCHOOL *
use temp, clear
hdfe asstschools_yn missions_yn post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC asstschools_yn missions_yn post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m missions_yn using tableA3.xls, keep(pre2549m post5097m post1898m missions_yn) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* MAINLINE * 
use temp, clear
hdfe mainline post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC mainline post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using tableA3.xls, keep(post5097m post1898m missions_yn) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* OTHER PROT *
use temp, clear
hdfe otprot post5097m, clear absorb(gridnum year) tol(0.001) keepvars(gridnum year latitude longitude pre2549m)
ols_spatial_HAC otprot post5097m, lat(latitude) lon(longitude) time(year) panel(gridnum) distcutoff(100) disp
outreg2 post5097m using tableA3.xls, keep(post5097m post1898m) addtext(post, 1850, sample, 1800-1932, clust, conley100) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append

****************
****************
*** TABLE A4 ***
****************
****************

use ghana_missions2, clear
* We create a few railroad dummies. 
* Based on 1932 only
drop dist2rail
ren dist2rail1932 dist2rail 
gen rail10 = (dist2rail <= 10 & dist2rail != .)
gen rail20 = (dist2rail > 10 & dist2rail <= 20 & dist2rail != .)
gen rail30 = (dist2rail > 20 & dist2rail <= 30 & dist2rail != .)
gen rail40 = (dist2rail > 30 & dist2rail <= 40 & dist2rail != .)
gen rail50 = (dist2rail > 40 & dist2rail <= 50 & dist2rail != .)
gen rail030 = (dist2rail <= 30 & dist2rail != .)

capture erase tableA4.xls
capture erase tableA4.txt
capture erase tableA4.tex
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
* 1932 *
local rail "rail10 rail20 rail30"
acreg missions_yn missions_yn1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1932 *
local rail "rail10 rail20 rail30 rail40"
acreg missions_yn missions_yn1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1932 *
local rail "rail10 rail20 rail30 rail40 rail50"
acreg missions_yn missions_yn1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
local rail "rail10 rail20 rail30"
* 1850 *
acreg missions_yn `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1850, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1850) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1875 *
acreg missions_yn missions_yn1850 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1875, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1875) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
* 1897 *
acreg missions_yn missions_yn1875 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1897, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA4.xls, addtext(year, 1897) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}

****************
****************
*** TABLE A5 ***
****************
****************

* The three outcomes one by one:
foreach Z in lmissions_num mainstat_yn asstschools_yn {

***** PANEL A *****

use ghana_missions2, clear
* We create a few more railroad variables. 
drop dist2rail
ren dist2rail1932 dist2rail 
gen rail030 = (dist2rail <= 30 & dist2rail != .)
gen rail030_nowest = (rail030 == 1 & dist2west18_030 == 0)
gen dist2placebo_030_norail = (dist2placebo_030 == 1 & rail030 == 0)
gen mainline = ((cmeth > 0 & cmeth != 0) | (cpresb > 0 & cpresb != 0))
* We create a few more variables for the missions. 
gen catho = (ccath > 0 & ccath != 0)
gen otprot = (coth > 0 & coth != 0)
foreach X in mainline catho otprot lmissions_num {
gen `X'97 = `X' if year == 1897
gen `X'75 = `X' if year == 1875
bysort gridcell: egen `X'1897 = max(`X'97)
bysort gridcell: egen `X'1875 = max(`X'75)
drop `X'97 `X'75
}
keep if year == 1932 | year == 1897

capture erase tableA5_`Z'.xls
capture erase tableA5_`Z'.txt
capture erase tableA5_`Z'.xls
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
* BASELINE/PRE-TRENDS
acreg `Z' missions_yn `Z'1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA5_`Z'.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
acreg `Z' missions_yn `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1897, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA5_`Z'.xls, addtext(year, 1897) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
* ETHNIC FE
foreach W in ethnic {
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
xi: acreg `Z' missions_yn `Z'1897 `rail' `geo' `ecogeo' `pop' `econ' area_sqkm i.`W' if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA5_`Z'.xls, addtext(year, 1897-1932, test, `W' FE) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
}
* IV STRAIGHT LINE
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
local ivrail "dist2iv_030"
xi: ivreg2 `Z' missions_yn `Z'1897 (`rail' = `ivrail') `geo' `ecogeo' `pop' `econ' area_sqkm lnode_dist  if year == 1932 & node_dist > 10, robust cluster(district31) first
outreg2 * using tableA5_`Z'.xls, addtext(year, 1897-1932, test, iv straight) keep(`rail') br se nocons coefastr bdec(3) sdec(4) rdec(2) noni nolabel
}
}

***** PANEL B: PANEL ANALYSIS FOR RAILROADS *****

use ghana_missions2, clear
keep if year >= 1897
* We create more railroad variables
gen rail030 = (dist2rail <= 30 & dist2rail != .)
sort gridcell year
foreach X of numlist 1(1)3 {
bysort gridcell: gen lag`X'rail030 = rail030[_n-`X']
bysort gridcell: gen lead`X'rail030 = rail030[_n+`X']
}
* We create more mission variables
gen mainline = ((cmeth > 0 & cmeth != 0) | (cpresb > 0 & cpresb != 0))
* We create the ethnic and district FE. 
gen ethnicyr = ethnic+string(year)
gen distyr = district31+string(year)
* We keep some variables only. 
keep gridcell gridnum year missions_yn *rail030 longitude latitude ethnic district31 lmissions_num mainstat_yn asstschools_yn mainline
save temp, replace

*** Effect of mission dummy ***

** BASELINE **
xi: reg2hdfespatial `Z' missions_yn rail030, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 rail* using tableA5_`Z'.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel

** CELL-LINEAR TRENDS **
set matsize 10000
use temp, clear
foreach X of numlist 1(1)1000 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
foreach X of numlist 1001(1)2091 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
set matsize 10000
set more on 
xi: reg `Z' missions_yn rail030 gridyear1-gridyear2091, robust cluster(district31)
outreg2 rail* using tableA5_`Z'.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}

****************
****************
*** TABLE A6 ***
****************
****************

* The three outcomes one by one:
foreach Z in mainline otprot catho {

*** PANEL A: CROSS-SECTIONAL/LONG-DIFFERENCE ANALYSIS ***

use ghana_missions2, clear
* We create a few more railroad variables. 
drop dist2rail
ren dist2rail1932 dist2rail 
gen rail030 = (dist2rail <= 30 & dist2rail != .)
gen rail030_nowest = (rail030 == 1 & dist2west18_030 == 0)
gen dist2placebo_030_norail = (dist2placebo_030 == 1 & rail030 == 0)
gen mainline = ((cmeth > 0 & cmeth != 0) | (cpresb > 0 & cpresb != 0))
* We create a few more variables for the missions. 
gen catho = (ccath > 0 & ccath != 0)
gen otprot = (coth > 0 & coth != 0)
foreach X in mainline catho otprot lmissions_num {
gen `X'97 = `X' if year == 1897
gen `X'75 = `X' if year == 1875
bysort gridcell: egen `X'1897 = max(`X'97)
bysort gridcell: egen `X'1875 = max(`X'75)
drop `X'97 `X'75
}
keep if year == 1932 | year == 1897

capture erase tableA6_`Z'.xls
capture erase tableA6_`Z'.txt
capture erase tableA6_`Z'.xls
quietly {
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
* BASELINE AND PARALLEL TRENDS
acreg `Z' `Z'1897 `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA6_`Z'.xls, addtext(year, 1932) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
acreg `Z' `geo' `ecogeo' `pop' `econ' `rail' area_sqkm if year == 1897, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA6_`Z'.xls, addtext(year, 1897) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
}
* ETHNIC FE
quietly {
foreach W in ethnic {
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
xi: acreg `Z' `Z'1897 `rail' `geo' `ecogeo' `pop' `econ' area_sqkm i.`W' if year == 1932, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 * using tableA6_`Z'.xls, addtext(year, 1897-1932, test, `W' FE) keep(`rail') br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}
}
}
}
* IV STRAIGHT LINE
foreach X in 50 {
foreach Y in 0 {
local geo "prec_mean alt_mean alt_sd soil5 histo_malaria"	
local ecogeo "port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10"
local pop "city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901"
local econ "ln_export_area slavemarket_strict_dist`X' minet_dist1932_`X'"
local rail "rail030"
local ivrail "dist2iv_030"
xi: ivreg2 `Z' `Z'1897 (`rail' = `ivrail') `geo' `ecogeo' `pop' `econ' area_sqkm lnode_dist  if year == 1932 & node_dist > 10, robust cluster(district31) first
outreg2 * using tableA6_`Z'.xls, addtext(year, 1897-1932, test, iv straight) keep(`rail') br se nocons coefastr bdec(3) sdec(4) rdec(2) noni nolabel
}
}

***** PANEL B: PANEL ANALYSIS FOR RAILROADS *****

use ghana_missions2, clear
keep if year >= 1897
* We create more railroad variables
gen rail030 = (dist2rail <= 30 & dist2rail != .)
sort gridcell year
foreach X of numlist 1(1)3 {
bysort gridcell: gen lag`X'rail030 = rail030[_n-`X']
bysort gridcell: gen lead`X'rail030 = rail030[_n+`X']
}
* We create more mission variables
gen mainline = ((cmeth > 0 & cmeth != 0) | (cpresb > 0 & cpresb != 0))
gen catho = (ccath > 0 & ccath != 0)
gen otprot = (coth > 0 & coth != 0)
* We create the ethnic and district FE. 
gen ethnicyr = ethnic+string(year)
gen distyr = district31+string(year)
* We keep some variables only. 
keep gridcell gridnum year missions_yn *rail030 longitude latitude ethnic district31 lmissions_num mainstat_yn asstschools_yn mainline otprot catho
save temp, replace

** BASELINE **
xi: reg2hdfespatial `Z' rail030, timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 rail* using tableA6_`Z'.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel

** CELL-LINEAR TRENDS **
set matsize 10000
use temp, clear
foreach X of numlist 1(1)1000 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
foreach X of numlist 1001(1)2091 {
gen gridyear`X' = 0
replace gridyear`X' = year if gridnum == `X'
}
set matsize 10000
set more on 

xi: reg `Z' rail030 gridyear1-gridyear2091, robust cluster(district31)
outreg2 rail* using tableA6_`Z'.xls, keep(*rail*) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel
}

****************
****************
*** TABLE A7 ***
****************
****************

use panel_cashc_africa, clear

capture erase tableA7.xls
capture erase tableA7.txt
capture erase tableA7.tex
use temp_cashc, clear
foreach W in missions_yn lmissions_num mainstat_yn asstschools_yn {
foreach Z in cashc {
foreach X in uk {
use temp_cashc, clear
xi: reg2hdfespatial `W' missions_yn l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* missions_yn using tableA7.xls, keep(*l*val_`X' missions_yn) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel 
}
}
}
foreach W in mainline otprot catho {
foreach Z in cashc {
foreach X in uk {
use temp_cashc, clear
xi: reg2hdfespatial `W' l`Z'val_`X', timevar(year) panelvar(gridnum) lat(latitude) lon(longitude) distcutoff(100) 
outreg2 *l*val_`X'* missions_yn using tableA7.xls, keep(*l*val_`X' missions_yn) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel 
}
}
}

****************
****************
*** TABLE A8 ***
****************
****************

cd "C:\Users\remij\Desktop\Replication Files JOEG\Stata"
set more off

use grid_africa_final, clear
gen countryethnic = country+ethnic
gen cntrydistrict2000 = country+district2000

*** PANEL A ***
foreach X in lbeach03_pro_num { 
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
local ours00murd2_milmin "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail1900_milmin30 density1800m dist2nationalcity10 slavery ln_export_area polygamy mines1900_50km"
* Baseline
areg `X' beach03_pro_yn area_sqkm `ours00murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
* Ethnic FE
xi: areg `X' beach03_pro_yn area_sqkm `ours00murd2' i.country, robust absorb(ethnic) cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* District FE
xi: areg `X' beach03_pro_yn area_sqkm `ours00murd2' i.country, robust absorb(district2000) cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Military-Mining
areg `X' beach03_pro_yn area_sqkm `ours00murd2_milmin', robust absorb(country) cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1900_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Never built 1916-1922
areg `X' beach03_pro_yn dist2proposed19162230_v2_00 area_sqkm `ours00murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
}
* IV 
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
foreach X in lbeach03_pro_num { 
xi: ivreg2 `X' beach03_pro_yn area_sqkm (dist2rail190030 = dist2emst30) `ours00murd2' i.country if emst_node == 0, robust  cluster(district2000)
outreg2 * using tableA8A.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}

*** PANEL B ***
foreach X in lroome24_num { 
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192430 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
local ours24murd2_milmin "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 dist2rail1924_milmin30 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy mines1900_50km"
* Baseline
areg `X' roome24_mis_yn area_sqkm `ours24murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel replace
* Ethnic FE
xi: areg `X' roome24_mis_yn area_sqkm `ours24murd2' i.country, robust absorb(ethnic) cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* District FE
xi: areg `X' roome24_mis_yn area_sqkm `ours24murd2' i.country, robust absorb(district2000) cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Military-Mining
areg `X' roome24_mis_yn area_sqkm `ours24murd2_milmin', robust absorb(country) cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1924_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Never built 1916-1922
areg `X' roome24_mis_yn dist2proposed19162230_v2_24 area_sqkm `ours24murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
}
* IV 
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
foreach X in lroome24_num { 
xi: ivreg2 `X' roome24_mis_yn area_sqkm (dist2rail192430 = dist2emst30) `ours24murd2' i.country if emst_node == 0, robust  cluster(district2000)
outreg2 * using tableA8B.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}

*** PANELS C-D ***
capture erase tableA8CD.xls
capture erase tableA8CD.txt
capture erase tableA8CD.tex
foreach X in prot_yn cath_yn { 
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192430 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
local ours24murd2_milmin "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 dist2rail1924_milmin30 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy mines1900_50km"
* Baseline
areg `X' area_sqkm `ours24murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Ethnic FE
xi: areg `X' area_sqkm `ours24murd2' i.country, robust absorb(ethnic) cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* District FE
xi: areg `X' area_sqkm `ours24murd2' i.country, robust absorb(district2000) cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Military-Mining
areg `X' area_sqkm `ours24murd2_milmin', robust absorb(country) cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1924_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Never built 1916-1922
areg `X' dist2proposed19162230_v2_24 area_sqkm `ours24murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
* IV 
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area polygamy"
xi: ivreg2 `X' area_sqkm (dist2rail192430 = dist2emst30) `ours24murd2' i.country if emst_node == 0, robust  cluster(district2000)
outreg2 * using tableA8CD.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail192430) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}

*** PANELS E-F ***
capture erase tableA8EF.xls
capture erase tableA8EF.txt
capture erase tableA8EF.tex
areg mainline area_sqkm `ours00murd2', robust absorb(country) cluster(district2000)
outreg2 * using table_africa_det_rail_denom.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
foreach X in mainline other { 
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190030 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
local ours00murd2_milmin "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail1900_milmin30 density1800m dist2nationalcity10 slavery ln_export_area polygamy mines1900_50km"
* Baseline
areg `X' area_sqkm `ours00murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Ethnic FE
xi: areg `X' area_sqkm `ours00murd2' i.country, robust absorb(ethnic) cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country ethnic, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* District FE
xi: areg `X' area_sqkm `ours00murd2' i.country, robust absorb(district2000) cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country district, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Military-Mining
areg `X' area_sqkm `ours00murd2_milmin', robust absorb(country) cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail1900_milmin30) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
* Never built 1916-1922
areg `X' dist2proposed19162230_v2_00 area_sqkm `ours00murd2', robust absorb(country) cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030 dist2proposed19162230*)  br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append adjr2
* IV 
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 density1800m dist2nationalcity10 slavery ln_export_area polygamy"
xi: ivreg2 `X' area_sqkm (dist2rail190030 = dist2emst30) `ours00murd2' i.country if emst_node == 0, robust  cluster(district2000)
outreg2 * using tableA8EF.xls, addtext(FE, country, cluster_SE, no, controls, ours00murd) keep(dist2rail190030) br se nocons coefastr bdec(3) sdec(3) rdec(2) noni nolabel append
}

****************
****************
*** TABLE A9 ***
****************
****************

*** COLUMN 1 ***

use panel_rail_africa, clear

* (1) BASELINE
reghdfe mission_yn rail30 if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(year, 1885, test, base) br se nocons coefastr bdec(3) sdec(3) rdec(4) noni nolabel replace
* (2) EXT MARGIN
reghdfe lnummission mission_yn rail30 if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(year, 1885, test, base) br se nocons coefastr bdec(3) sdec(3) rdec(4) noni nolabel append
* (3) MAINLINE
reghdfe mainline rail30 if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(year, 1885, test, base) br se nocons coefastr bdec(3) sdec(3) rdec(4) noni nolabel append
* (4) OT PROT
reghdfe otprot rail30 if year >= 1885, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(year, 1885, test, base) br se nocons coefastr bdec(3) sdec(3) rdec(4) noni nolabel append

*** COLUMN 2 ***

use panel_cashc_africa, clear

* (1) BASELINE
reghdfe mission_yn lcellvalue0all, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(test, base) br se nocons coefastr bdec(3) sdec(3) rdec(3) noni nolabel append
* (2) EXT MARGIN
reghdfe lnummission mission_yn lcellvalue0all, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(test, base) br se nocons coefastr bdec(3) sdec(3) rdec(3) noni nolabel append
* (3) MAINLINE
reghdfe mainline lcellvalue0all, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(test, base) br se nocons coefastr bdec(3) sdec(3) rdec(3) noni nolabel append
* (4) OT PROT
reghdfe otprot lcellvalue0all, absorb(gridcell year cntryyr) vce(cluster cntrydistrict2000)
outreg2 * using tableA9.xls, addtext(test, base) br se nocons coefastr bdec(3) sdec(3) rdec(3) noni nolabel append

*****************
*****************
*** TABLE A10 ***
*****************
*****************

*** PANEL A ***

use grid_africa_final, clear
gen countrydist = country+district2000
gen countryreg = country+region2000
gen countryethnic = country+ethnic
capture erase tableA10A.xls
capture erase tableA10A.tex
capture erase tableA10A.txt
local std "prec_mean soil5 malaria dist2coast city1400 city1800 dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m ln_export_area"
local ours24murd2 "yrstudy_yn yrstudy1924 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail192410 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1924all mines1924_50km polygamy"
local ours00murd2 "yrstudy_yn yrstudy1900 prec_mean alt_mean alt_std soil5 malaria tsetse dist2slaveport_10km lndist2coast city1400 city1800 missing_murdock centra nevercolonised date_col ldist2muslimcentre dist2river_nav10km dist2lake10 dist2explorer10 dist2rail190010 density1800m dist2nationalcity10 lcitypop1900_10 lurbc1900 lrurc1900 slavery ln_export_area lcellvalue1900all mines1900_50km polygamy"
local type "in_BEACH_1850 in_BEACH_185181"
foreach Z in lnltc2010 {
foreach X in beach03_pro_yn { 
xi: reg `Z' `X' area_sqkm `ours00murd2' i.country, robust clust(countrydist)
outreg2 * using tableA10A.xls, keep(`X') addtext(FE, `W', cluster_SE, no, controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
foreach X in roome24_mis_yn { 
xi: reg `Z' `X' area_sqkm `ours24murd2' i.country, robust clust(countrydist)
outreg2 * using tableA10A.xls, keep(`X') addtext(FE, `W', cluster_SE, no, controls, ours00murd) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
}
foreach W in countryreg ethnic countryethnic countrydist {
foreach Z in lnltc2010 {
foreach X in beach03_pro_yn { 
xi: areg `Z' `X' area_sqkm `ours00murd2' i.country, robust absorb(`W') clust(countrydist)
outreg2 * using tableA10A.xls, keep(`X') addtext(FE, `W', cluster_SE, no, controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
foreach X in roome24_mis_yn { 
xi: areg `Z' `X' area_sqkm `ours24murd2' i.country, robust absorb(`W') clust(countrydist)
outreg2 * using tableA10A.xls, keep(`X') addtext(FE, `W', cluster_SE, no, controls, ours00murd) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append adjr2
}
}
}

*** PANEL B ***

use ghana_missions2, clear
gen whole = 1
capture erase tableA10B.xls
capture erase tableA10B.tex
capture erase tableA10B.txt
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
foreach W in whole province_2000 ethnic ethnic district_2000 {
foreach X of varlist lnltc2010 {
xi: acreg `X' missions_yn `stdctrls' area_sqkm i.`W' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA10B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, std, FE, `W') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg `X' missions_yn `stdctrls' area_sqkm i.`W' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA10B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, std, FE, `W') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
foreach W in whole {
foreach X of varlist lnltc2010 {
xi: acreg `X' missions_yn `ourctrls' `type' area_sqkm i.`W' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA10B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, std, FE, `W') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg `X' missions_yn `ourctrls' `type' area_sqkm i.`W' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA10B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, std, FE, `W') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

*****************
*****************
*** TABLE A11 ***
*****************
*****************

use ghana_missions2, clear

capture erase tableA11.xls
capture erase tableA11.txt
capture erase tableA11.tex
*** PANEL A ***
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
* 1900
acreg `X' missions_yn ldist2mis1900 area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1900 using tableA11.xls, keep(missions_yn* ldist2mis1900) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1900 `stdctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn* ldist2mis1900 using tableA11.xls, keep(missions_yn* ldist2mis1900) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1900 `ourctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1900 using tableA11.xls, keep(missions_yn* ldist2mis1900) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1900 `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1900 using tableA11.xls, keep(missions_yn* ldist2mis1900) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 1924
acreg `X' missions_yn ldist2mis1924 area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1924 using tableA11.xls, keep(missions_yn* ldist2mis1924) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1924  `stdctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn* ldist2mis1924 using tableA11.xls, keep(missions_yn* ldist2mis1924) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1924  `ourctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1924 using tableA11.xls, keep(missions_yn* ldist2mis1924) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn ldist2mis1924  `ourctrls' `type' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* ldist2mis1924 using tableA11.xls, keep(missions_yn* ldist2mis1924) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
*** PANEL B ***
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
* 1900
acreg `X' missions_yn1900_* area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1900_* `stdctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1900_* `ourctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1900_* `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 1924
acreg `X' missions_yn1924_* area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1924_*  `stdctrls' area_sqkm  if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1924_*  `ourctrls' area_sqkm  if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn1924_*  `ourctrls' `type' area_sqkm  if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn* using tableA11.xls, keep(missions_yn*) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}

*****************
*****************
*** TABLE A12 ***
*****************
*****************

* See the folder "Appendix Table A12" in the main folder.

*****************
*****************
*** TABLE A13 ***
*****************
*****************

use ghana_missions2, clear
* We create the interaction variables. 
gen rail = (dist2rail1932 <= 30)
gen int_rail = missions_yn * rail
gen cashc = 0
foreach X in palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa {
replace cashc = 1 if `X' == 1 
}
gen int_cashc = missions_yn * cashc

capture erase tableA13.xls
capture erase tableA13.txt
capture erase tableA13.tex
foreach Y in rail {
foreach Z in cashc {
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' missions_yn int_rail int_cashc rail cashc area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn beach03_pro_yn int_rail int_cashc) addtext(spec, 1900, depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `stdctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn beach03_pro_yn int_rail int_cashc) addtext(spec, 1900, depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ssactrls1900' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn beach03_pro_yn int_rail int_cashc) addtext(spec, 1900, depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ourctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn beach03_pro_yn int_rail int_cashc) addtext(spec, 1900, depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn beach03_pro_yn int_rail int_cashc) addtext(spec, 1900, depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn roome24_mis_yn int_rail int_cashc) addtext(spec, 1924, depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `stdctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn roome24_mis_yn int_rail int_cashc) addtext(spec, 1924, depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ssactrls1924' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn roome24_mis_yn int_rail int_cashc) addtext(spec, 1924, depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ourctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn roome24_mis_yn int_rail int_cashc) addtext(spec, 1924, depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn int_rail int_cashc rail cashc `ourctrls' `type' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn int_rail int_cashc rail cashc using tableA13.xls, keep(missions_yn roome24_mis_yn int_rail int_cashc) addtext(spec, 1924, depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

****************************
****************************
*** TABLE A14, TABLE A15 ***
****************************
****************************

use ghana_missions2, clear

*** TABLE A14 ***
capture erase tableA14.xls
capture erase tableA14.txt
capture erase tableA14.tex
foreach X in lupop5000_2000 urbsh5000_2000 lpop_2000 induserv_sh mfgfire_sh cogn_br_sh rel_chri yrseduc educ_prim_comp zlen_5obscell zwei_5obscell compfert3549 compnetfert3549 compmort3549  {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' missions_yn `stdctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using tableA14.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA14.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA14.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `stdctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using tableA14.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA14.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA14.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}

*** TABLE A15 ***
capture erase tableA15.xls
capture erase tableA15.txt
capture erase tableA15.tex
foreach X in yrseduc educ_prim_comp zlen_5obscell zwei_5obscell compnetfert3549 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn `type' using tableA15.xls, keep(missions_yn beach03_pro_yn `type') addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn `type' using tableA15.xls, keep(missions_yn roome24_mis_yn `type') addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* need to redo 1 and 3, which is beach for yrseduc educ_prim_comp
run gls_sptl.005.do
keep if year == 1900
*gls_sptl yrseduc missions_yn prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50 period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690 area_sqkm, sptlcoef(1) crdlst(latitude longitude) cut(100) 
*gls_sptl educ_prim_comp missions_yn prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50 period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690 area_sqkm, sptlcoef(1) crdlst(latitude longitude) cut(100) 

*****************
*****************
*** TABLE A16 ***
*****************
*****************

*** PANEL A ***
use ghana_missions2, clear
gen protestant_yn = ((cmeth > 0 & cmeth !=.) | (cpresb > 0 & cpresb != .)) 
capture erase tableA16A.xls
capture erase tableA16A.txt
capture erase tableA16A.tex
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' protestant_yn catho_yn area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `stdctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ssactrls1900' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ourctrls' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ourctrls' `type' area_sqkm if year == 1900, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `stdctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ssactrls1924' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ourctrls' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' protestant_yn catho_yn `ourctrls' `type' area_sqkm if year == 1924, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16A.xls, keep(*protestant_yn* catho_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}

*** PANEL B ***
use ghana_missions2, clear
* Abandoned mission dummies
foreach X in 1900 1924 {
gen abandon`X'_yn = 0
replace abandon`X'_yn = 1 if year == `X' & missions_yn == 0 & firstyear != . & firstyear < `X'
tab missions_yn abandon`X'_yn if year == `X', m
}
capture erase tableA16B.xls
capture erase tableA16B.txt
capture erase tableA16B.tex
foreach X of varlist lnltc2010 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ssactrls1900 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1900 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1900 minet_dist50 polygamy"
local ssactrls1924 "soil5 prec_mean ldist2coast histo_malaria tsi city1800 yrstudy_yn yrstudy1924 missing_murdock nevercolonised date_col centra ldist2muslimcentre port1850_yn dist2riv_navigable10 ldist2explorer dist2rail30 density1800m city10k_1900 lurbc1900 lrurc1900 slavery ln_export_area lgridvalue1924 minet_dist50 polygamy"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
local type "period1 period2 mainstat_yn asstschools_yn eurononmain4690 euromain4690"
local typenum "period1 period2 lmissions_num mainstat_yn asstschools_yn eurononmain4690 euromain4690"
acreg `X' missions_yn  area_sqkm if year == 1900 & missions_yn == 1 | abandon1900_yn == 1, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `stdctrls' area_sqkm if year == 1900 & missions_yn == 1 | abandon1900_yn == 1, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using tableA16B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ssactrls1900' area_sqkm if year == 1900 & missions_yn == 1 | abandon1900_yn == 1, latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn beach03_pro_yn using tableA16B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' area_sqkm if year == 1900 & missions_yn == 1 | abandon1900_yn == 1, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1900 & missions_yn == 1 | abandon1900_yn == 1, latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn beach03_pro_yn using tableA16B.xls, keep(missions_yn beach03_pro_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn area_sqkm if year == 1924 & (missions_yn == 1 | abandon1924_yn == 1), latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, no) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `stdctrls' area_sqkm if year == 1924 & (missions_yn == 1 | abandon1924_yn == 1), latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using tableA16B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, standard) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ssactrls1924' area_sqkm if year == 1924 & (missions_yn == 1 | abandon1924_yn == 1), latitude(latitude) longitude(longitude) dist(100) spatial 
outreg2 missions_yn roome24_mis_yn using tableA16B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ssa) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' area_sqkm if year == 1924 & (missions_yn == 1 | abandon1924_yn == 1), latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' missions_yn `ourctrls' `type' area_sqkm if year == 1924 & (missions_yn == 1 | abandon1924_yn == 1), latitude(latitude) longitude(longitude) dist(100) spatial
outreg2 missions_yn roome24_mis_yn using tableA16B.xls, keep(missions_yn roome24_mis_yn) addtext(depvar, `X', controls, ourstype) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
